﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SaleWebsite.library;
using System.Data;
using MySql.Data;
using MySql.Data.MySqlClient;
namespace SaleWebsite.Models
{
    public class Group
    {
        public ulong Id{get;set;}
        public string Name{get;set;}
        public Group(ulong id,string name)
        {

            this.Id = id;
            this.Name = name;
        }
        public ulong Insert()
        {
            
           try
           {
               return MySqlImplement.GetInstance().ExcuteQuery(Params.GetAllParams(this), "Sale_group_insert");
           }
           catch (System.Exception ex)
           {
           	throw ex;
           }
           
        }
        public static DataSet GetAll()
        {
            return MySqlImplement.GetInstance().GetQuery("group_getall");
        }
        public Group(DataRow row)
        {
            this.Id = ulong.Parse(row["id"].ToString());
            this.Name = row["name"].ToString();
        }
        public List<Group>Convert()
        {
            return null;
        }
        public  int Delete()
        {
            return MySqlImplement.GetInstance().ExcuteCommand(Params.GetAllParams(this),"group_delete");
        }
        public int Save()
        {
          try
          {
              return MySqlImplement.GetInstance().ExcuteCommand(Params.GetAllParams(this), "group_update");
          }
          catch (System.Exception ex)
          {
          	throw ex;
          }
        }
        public DataSet GetGroupById()
        {
            return MySqlImplement.GetInstance().GetQuery("group_get_id", Params.GetAllParams(this));
        }
    }

}